﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace SCS.Web.UI.WebControls.Dialogs.Test.Membership
{
    public partial class Register : System.Web.UI.UserControl
    {
        public string ContextKey;

        private int _stepIndex;

        protected void Page_Load(object sender, EventArgs e)
        {
            string[] args = ContextKey.Split('#');

            _stepIndex = (args.Length > 1) ? int.Parse(args[1]) : 0;

            registerWizard.ActiveViewIndex = _stepIndex;
                     
            cancelButton.Attributes["dialog-action"] = "{url:'membership/Login.htm'}";
   
            switch (_stepIndex)
            {
                case 0:
                    backButton.Visible = false;
                    proceedButton.Value = "Next >";
                    proceedButton.Attributes["dialog-action"] = "{contextKey:'#1', 'defer':true}";
                    dialogMessage.InnerHtml = "Please complete this form and click the Next button.";
                    break;

                case 1:
                    //backButton.Visible = true;
                    backButton.Visible = false;
                    backButton.Attributes["dialog-action"] = "{contextKey:'#0'}";
                    proceedButton.Value = "Finish";
                    proceedButton.Attributes["dialog-action"] = "{contextKey:'#2', 'defer':true}";
                    dialogMessage.InnerHtml = "Please enter your address and click the Finish button.";
                    break;

                case 2:
                    backButton.Visible = false;
                    proceedButton.Visible = false;
                    dialogMessage.InnerHtml = "Your registration was completed successfully.";
                    cancelButton.Value = "Return";
                    break;
            }            
        }

        public string GetPropertyArray()
        {
            return string.Format("{{'stepIndex': {0}}}", _stepIndex);
        }
    }
}